"""
@author: wy
@file: login_func.py
@time: 2023/12/4 17:08
"""
def login(username,password,user_info):

    if username in user_info and user_info[username]['password'] == password:
        return True



def register(username,password,balance,user_info):
    if username not in user_info:
        user_info[username]=username
        user_info[username] = {'password':password,'balance':balance}
        return True
    return False

def inputcash(username,user_info,money):
    print(f"您的账户余额为{user_info[username]['balance']}")
    user_info[username]['balance'] += money
    print(f"已成功存入，您的账户余额为{user_info[username]['balance']}")

def withdraw(username,user_info,money):
    print(f"您的账户余额为{user_info[username]['balance']}")
    if money <= user_info[username]['balance']:
        user_info[username]['balance'] -= money
        print(f"已取出，您的账户余额为{user_info[username]['balance']}")
        return
    else:
        print(f"您的账户余额不足，账户余额为{user_info[username]['balance']}")


def transfer(username,people,user_info,money):
    print(f"您的账户余额为{user_info[username]['balance']}")
    if people in user_info and money <= user_info[username]['balance']:
        user_info[username]['balance'] -= money
        user_info[people]['balance'] += money
        print(f"已成功转出，您的账户余额为{user_info[username]['balance']}")
        return
    else:
        print("请输入正确的转入账户名或确保您的余额充足！")

